package net.sql;

import java.lang.reflect.Method;

import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import java.lang.String;

public class UpdateJar {

	public static void main(String[] args) {
		try {
			ClassPool cp = ClassPool.getDefault();
			cp.insertClassPath("G:\\jd-gui-0.3.3.windows");
			// 获得类文件名
			CtClass cc = cp.get("org.apache.catalina.ha.tcp.SimpleTcpCluster");
			// class的包?
			// 设置方法?的参?

			// 指定哪个方法
			CtMethod m = cc.getDeclaredMethod("startInternal");
			final StringBuffer body = new StringBuffer();
			body.append("{");
			body.append("try{");
			body.append("checkDefaults();");
			body.append("registerClusterValve();");
			body.append("this.channel.addMembershipListener(this);");
			body.append("this.channel.addChannelListener(this);");
			body.append("this.channel.start(this.channelStartOptions);");
			body.append(" if (this.clusterDeployer != null) {this.clusterDeployer.start();}");
			body.append("registerMember(this.channel.getLocalMember(false));");
			body.append("}catch (Exception x) {throw new org.apache.catalina.LifecycleException(x);}");
			body.append("setState(org.apache.catalina.LifecycleState.STARTING);");
			body.append("}");
			m.setBody(body.toString());

			cc.writeFile("G:\\jd-gui-0.3.3.windows\\aa");
			System.out.println("ok");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
